package com.star.wellconnect;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;

public class MoodFragment extends Fragment{
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
		return inflater.inflate(R.layout.fragment_mood, container, false);
	}
	
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState){
		super.onViewCreated(view, savedInstanceState);
		// Generate Graph
		int num = 150;
		GraphViewData[] sinData = new GraphViewData[num];
		GraphViewData[] cosData = new GraphViewData[num];
		GraphViewData[] ranData = new GraphViewData[num];
		double v = 0;
		for(int i = 0; i < num; i++){
			v += 0.2;
			sinData[i] = new GraphViewData(i, Math.sin(v));
			cosData[i] = new GraphViewData(i, Math.cos(v));
			ranData[i] = new GraphViewData(i, Math.sin(Math.random()*v));
		}
		GraphViewSeries sinSeries = new GraphViewSeries("Sine Curve", null, sinData);
		GraphViewSeries cosSeries = new GraphViewSeries("Cos Curve", null, cosData);
		GraphViewSeries ranSeries = new GraphViewSeries("Random Curve", null, ranData);
		
		LineGraphView moodGraph = new LineGraphView(getActivity(), "Mood Graph");
		moodGraph.addSeries(sinSeries);
		moodGraph.addSeries(cosSeries);
		moodGraph.addSeries(ranSeries);
		moodGraph.setViewPort(2, 10);
		moodGraph.setScalable(true);
		
		moodGraph.setShowLegend(true);
		
		((LinearLayout) view.findViewById(R.id.mood_graph)).addView(moodGraph);
		
	}
}
